<?php


namespace App\Models;


use App\Services\CommonService;
use Illuminate\Database\Eloquent\Model;

class AppletsIndexListCategory extends Model
{
    protected $table = 'sp_index_list_category';
    protected $primaryKey = 'id';
    public $timestamps = false;

    const STATUS_NOT_SHOW = 1;//隐藏
    const STATUS_YES_SHOW = 2;//显示

    const REDIS_CATEGORY_KEY = 'index_list_category';
    const REDIS_FIRST_CATEGORY_KEY = 'index_list_category_first';

    public static function getFirstList(){
        $category = AppletsIndexListCategory::where(['status'=>AppletsIndexListCategory::STATUS_YES_SHOW,'is_delete'=>CommonService::IS_DELETE_NOT])
            ->select('id','name','title')
            ->orderBy('sort','asc')
            ->first();
        return obToArray($category);
    }

    public static function getList(){
        $category = AppletsIndexListCategory::where(['status'=>AppletsIndexListCategory::STATUS_YES_SHOW,'is_delete'=>CommonService::IS_DELETE_NOT])
            ->select('id','name','title')
            ->orderBy('sort','asc')
            ->orderBy('id','asc')
            ->get();
        return obToArray($category);
    }

}
